﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MiniErp.Entity.DataStreams.DOs.Notice;
using MiniErp.Entity.DataStreams.DTOs.Notice;
using MiniErp.Service.BusinessService.IService.Notice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MiniErp.Core.Controllers.Notice
{
    /// <summary>
    /// 公告系统控制器
    /// </summary>
    [Route("Notices")]
    public class NoticeController : ApiControllers
    {
        private readonly INoticeService _noticeService;
        public NoticeController(INoticeService noticeService)
        {
            _noticeService = noticeService;
        }
        /// <summary>
        /// 查询所有公告 //分页
        /// </summary>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        [HttpGet]
        [Route("GetAllNoticesAsync")]
        public Task<List<NoticesDTO>> GetAllNoticesAsync(int page, int num)
        {
            return _noticeService.GetAllNoticesAsync(page, num);
        }

        /// <summary>
        ///  指定公告发起人编号查询公告 //分页
        /// </summary>
        /// <param name="uid">公告编写人编号</param>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        [HttpGet]
        [Route("GetNoticesBySystemsIdAsync")]
        public Task<List<NoticesDTO>> GetNoticesBySystemsIdAsync(int uid, int page, int num)
        {
            return _noticeService.GetNoticesBySystemsIdAsync(uid, page, num);
        }

        /// <summary>
        ///  指定岗位编号以及更新时间查询公告 //分页
        /// </summary>
        ///<param name="jobsid">岗位编号</param>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        /// <param name="starttime">开始时间</param>
        /// <param name="endtime">结束时间</param>
        [HttpGet]
        [Route("GetNoticesByJobsIdAndTimeAsync")]
        public Task<List<NoticesDTO>> GetNoticesByJobsIdAndTimeAsync(DateTime starttime, DateTime endtime, int jobsid, int page, int num)
        {
            return _noticeService.GetNoticesByJobsIdAndTimeAsync(starttime, endtime, jobsid, page, num);
        }
        /// <summary>
        /// 新增公告
        /// </summary>
        /// <param name="NoticesDTO">新增岗位系统权限DTO</param>
        [HttpPost]
        [Route("AddNoticesAsync")]
        public Task<bool> AddNoticesAsync(AddNoticesDTO NoticesDTO)
        {
            return _noticeService.AddNoticesAsync(NoticesDTO);
        }
        /// <summary>
        /// 删除公告
        /// </summary>
        /// <param name="noticesId">公告编号</param>
        [HttpDelete]
        [Route("DeleteNoticesAsync")]
        public Task<bool> DeleteNoticesAsync(int noticesId)
        {
            return _noticeService.DeleteNoticesAsync(noticesId);
        }

        /// <summary>
        /// 按时间获取公告 //分页
        /// </summary>
        /// <param name="starttime">开始时间</param>
        /// <param name="endtime">结束时间</param>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        [HttpGet]
        [Route("GetAllNoticesByTimeAsync")]
        public Task<List<NoticesDTO>> GetAllNoticesByTimeAsync(DateTime starttime, DateTime endtime, int page, int num)
        {
            return _noticeService.GetAllNoticesByTimeAsync(starttime, endtime, page, num);
        }
        /// <summary>
        /// 修改公告
        /// </summary>
        /// <param name="NoticesDTO">修改公告DTO</param>
        [HttpPost]
        [Route("UpdateNoticesAsync")]
        public Task<bool> UpdateNoticesAsync(UpdateNoticesDTO NoticesDTO)
        {
            return _noticeService.UpdateNoticesAsync(NoticesDTO);
        }
    }
}
